import { Form, Input, Select } from '@alifd/next';
import { useRequest } from 'ice';
import { modulesList } from '../services';

interface Props {
  submit: (values: any, item: any) => void;
  field: any;
}

function Filter({ submit, field }: Props) {
  const { data } = useRequest<any, string[]>(modulesList, { manual: false });
  return (
    <Form responsive colon fullWidth labelAlign="left" labelTextAlign="left" field={field} onChange={submit}>
      <Form.Item colSpan={4} name="clazz" label="类名">
        <Input hasClear />
      </Form.Item>
      <Form.Item colSpan={4} name="name" label="方法名">
        <Input placeholder="请输入" hasClear />
      </Form.Item>
      <Form.Item colSpan={4} name="path" label="路径">
        <Input placeholder="请输入" hasClear />
      </Form.Item>
      <Form.Item colSpan={4} name="modules" label="模块">
        <Select placeholder="请选择" hasClear dataSource={data} />
      </Form.Item>
    </Form>
  );
}

export default Filter;
